package net.suplementos.web.action;

import net.suplementos.negocio.MarketingDelegate;
import net.suplementos.pojo.Cliente;
import net.suplementos.pojo.Promocao;
import net.suplementos.servico.MarketingServico;
import net.suplementos.web.LocalConstantes;

import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.InterceptorRef;
import org.apache.struts2.convention.annotation.InterceptorRefs;
import org.apache.struts2.convention.annotation.Namespace;
import org.apache.struts2.convention.annotation.Result;

import com.opensymphony.xwork2.ActionSupport;

@Namespace("/contatarCliente")
@InterceptorRefs({
	@InterceptorRef(value = "store", params = {"operationMode", "AUTOMATIC"}),
	@InterceptorRef("defaultStack")
})
public class ContatarClienteAction extends ActionSupport {
	
	private Promocao promocao;
	private MarketingServico marketingServico = MarketingDelegate.getInstance();

	@Action(value = "abrirContatar", results = {
		@Result(name = SUCCESS, location = LocalConstantes.LOCAL_JSP_MARKETING_CONTATAR_CLIENTE + "/contatar.jsp") 
	})
    public String abrirContatar() throws Exception {
        return SUCCESS;
    }

	@Action(value = "contatar", results = {
		@Result(name = SUCCESS, params = {"actionName", "consultar", "namespace", "/manterPromocao"}, type = "redirectAction") 
	})
	public String contatar() throws Exception {
		addActionMessage(getText("contatar.clientes.mensagem.sucesso"));
		marketingServico.contatarCliente(promocao);
		return SUCCESS;
	}

	public Promocao getPromocao() {
		return promocao;
	}

	public void setPromocao(Promocao promocao) {
		this.promocao = promocao;
	}
}
